package com.equdao.car_violation_inquiry.controller;

import com.equdao.car_violation_inquiry.pojo.LocalBaseCarDO;
import com.equdao.car_violation_inquiry.service.LocalBaseCarService;
import com.equdao.car_violation_inquiry.service.LocalService;
import com.equdao.car_violation_inquiry.utils.UploadLocalCsvUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import sun.rmi.runtime.Log;

import java.util.List;

/**
 * @Author: 杨忠强
 * @Date: 2018/5/30 15:46
 * @Description:
 */

@Slf4j
@RestController
public class LocalController {

    @Autowired
    private LocalService localService;


    @GetMapping("/findLocalViolationRecord")
    public String findLocalViolationRecord() {
        //万物数据
        //ViolationInfoDTO violationInfo = clientService.findViolationInfo(baseCarBean);

        // 1.读取本地数据库数据
        List<LocalBaseCarDO> list = localService.findLocalBaseCar();
        int pingjun = list.size()/20;
        int yushu = list.size()%20;

        List<LocalBaseCarDO> list1 = list.subList(0, pingjun);
        List<LocalBaseCarDO> list2 = list.subList(pingjun, pingjun*2);
        List<LocalBaseCarDO> list3 = list.subList(pingjun*2, pingjun*3);
        List<LocalBaseCarDO> list4 = list.subList(pingjun*3, pingjun*4);
        List<LocalBaseCarDO> list5 = list.subList(pingjun*4, pingjun*5);
        List<LocalBaseCarDO> list6 = list.subList(pingjun*5, pingjun*6);
        List<LocalBaseCarDO> list7 = list.subList(pingjun*6, pingjun*7);
        List<LocalBaseCarDO> list8 = list.subList(pingjun*7, pingjun*8);
        List<LocalBaseCarDO> list9 = list.subList(pingjun*8, pingjun*9);
        List<LocalBaseCarDO> list10 = list.subList(pingjun*9, pingjun*10);

        List<LocalBaseCarDO> list11 = list.subList(pingjun*10, pingjun*11);
        List<LocalBaseCarDO> list12 = list.subList(pingjun*11, pingjun*12);
        List<LocalBaseCarDO> list13 = list.subList(pingjun*12, pingjun*13);
        List<LocalBaseCarDO> list14 = list.subList(pingjun*13, pingjun*14);
        List<LocalBaseCarDO> list15 = list.subList(pingjun*14, pingjun*15);
        List<LocalBaseCarDO> list16 = list.subList(pingjun*15, pingjun*16);
        List<LocalBaseCarDO> list17 = list.subList(pingjun*16, pingjun*17);
        List<LocalBaseCarDO> list18 = list.subList(pingjun*17, pingjun*18);
        List<LocalBaseCarDO> list19 = list.subList(pingjun*18, pingjun*19);
        List<LocalBaseCarDO> list20 = list.subList(pingjun*19, pingjun*20+yushu);


        //2.选择逐条查询返回数据解析放入数据库   恒达
//        System.out.println("第1部分:"+list1.size()+"条");
//        Integer issusses1 = localService.findWMViolationInfo(list1);
//        System.out.println("第2部分:"+list2.size()+"条");
//        Integer issusses2 = localService.findWMViolationInfo(list2);
//        System.out.println("第3部分:"+list3.size()+"条");
//        Integer issusses3 = localService.findWMViolationInfo(list3);
//        System.out.println("第4部分:"+list4.size()+"条");
//        Integer issusses4 = localService.findWMViolationInfo(list4);
//        System.out.println("第5部分:"+list5.size()+"条");
//        Integer issusses5 = localService.findWMViolationInfo(list5);
//        System.out.println("第6部分:"+list6.size()+"条");
//        Integer issusses6 = localService.findWMViolationInfo(list6);
//        System.out.println("第7部分:"+list7.size()+"条");
//        Integer issusses7 = localService.findWMViolationInfo(list7);
//        System.out.println("第8部分:"+list8.size()+"条");
//        Integer issusses8 = localService.findWMViolationInfo(list8);
//        System.out.println("第9部分:"+list9.size()+"条");
//        Integer issusses9 = localService.findWMViolationInfo(list9);
//        System.out.println("第10部分:"+list10.size()+"条");
//        Integer issusses10 = localService.findWMViolationInfo(list10);

//        System.out.println("第11部分:"+list11.size()+"条");
//        Integer issusses11 = localService.findWMViolationInfo(list11);
//        System.out.println("第12部分:"+list12.size()+"条");
//        Integer issusses12 = localService.findWMViolationInfo(list12);
//        System.out.println("第13部分:"+list13.size()+"条");
//        Integer issusses13 = localService.findWMViolationInfo(list13);
//        System.out.println("第14部分:"+list14.size()+"条");
//        Integer issusses14 = localService.findWMViolationInfo(list14);
//        System.out.println("第15部分:"+list15.size()+"条");
//        Integer issusses15 = localService.findWMViolationInfo(list15);
//        System.out.println("第16部分:"+list16.size()+"条");
//        Integer issusses16 = localService.findWMViolationInfo(list16);
//        System.out.println("第17部分:"+list17.size()+"条");
//        Integer issusses17 = localService.findWMViolationInfo(list17);
//        System.out.println("第18部分:"+list18.size()+"条");
//        Integer issusses18 = localService.findWMViolationInfo(list18);
//        System.out.println("第19部分:"+list19.size()+"条");
//        Integer issusses19 = localService.findWMViolationInfo(list19);
//        System.out.println("第20部分:"+list20.size()+"条");
//        Integer issusses20 = localService.findWMViolationInfo(list20);

//
//        // 2.选择逐条查询返回数据解析放入数据库   万物
        System.out.println("第1部分:"+list1.size()+"条");
        Integer issusses1 = localService.findWWViolationInfo(list1);
        System.out.println("第2部分:"+list2.size()+"条");
        Integer issusses2 = localService.findWWViolationInfo(list2);
        System.out.println("第3部分:"+list3.size()+"条");
        Integer issusses3 = localService.findWWViolationInfo(list3);
        System.out.println("第4部分:"+list4.size()+"条");
        Integer issusses4 = localService.findWWViolationInfo(list4);
        System.out.println("第5部分:"+list5.size()+"条");
        Integer issusses5 = localService.findWWViolationInfo(list5);
        System.out.println("第6部分:"+list6.size()+"条");
        Integer issusses6 = localService.findWWViolationInfo(list6);
        System.out.println("第7部分:"+list7.size()+"条");
        Integer issusses7 = localService.findWWViolationInfo(list7);
        System.out.println("第8部分:"+list8.size()+"条");
        Integer issusses8 = localService.findWWViolationInfo(list8);
        System.out.println("第9部分:"+list9.size()+"条");
        Integer issusses9 = localService.findWWViolationInfo(list9);
        System.out.println("第10部分:"+list10.size()+"条");
        Integer issusses10 = localService.findWWViolationInfo(list10);


        System.out.println("第11部分:"+list11.size()+"条");
        Integer issusses11 = localService.findWWViolationInfo(list11);
        System.out.println("第12部分:"+list12.size()+"条");
        Integer issusses12 = localService.findWWViolationInfo(list12);
        System.out.println("第13部分:"+list13.size()+"条");
        Integer issusses13 = localService.findWWViolationInfo(list13);
        System.out.println("第14部分:"+list14.size()+"条");
        Integer issusses14 = localService.findWWViolationInfo(list14);
        System.out.println("第15部分:"+list15.size()+"条");
        Integer issusses15 = localService.findWWViolationInfo(list15);
        System.out.println("第16部分:"+list16.size()+"条");
        Integer issusses16 = localService.findWWViolationInfo(list16);
        System.out.println("第17部分:"+list17.size()+"条");
        Integer issusses17 = localService.findWWViolationInfo(list17);
        System.out.println("第18部分:"+list18.size()+"条");
        Integer issusses18 = localService.findWWViolationInfo(list18);
        System.out.println("第19部分:"+list19.size()+"条");
        Integer issusses19 = localService.findWWViolationInfo(list19);
        System.out.println("第20部分:"+list20.size()+"条");
        Integer issusses20 = localService.findWWViolationInfo(list20);
        return "接受到请求,正在执行";
    }


}
